﻿var setupContact = function () {
    $("#right_nav .contact li").mouseenter(function () {
        $("#tel").removeClass("default");
        
        var elId = $(this).attr("id");
        if (elId == "tel") {
            $("#right_nav .contact .text").show();
        } else {
            $("#right_nav .contact .text").hide();
        }
    })
    .mouseleave(function () {
        $("#right_nav .contact .text").hide();
    });
    
    $("#right_nav .contact").mouseleave(function (ev) {
        $("#right_nav .contact .text").show();
        $("#tel").addClass("default");
    });
};

var createDetailDialog = function (postUrl) {
    $(document.body).append("<div id='detail_dialog'></div>");
    var el = $("#detail_dialog");
    el.dialog({
        width: 600,
        height: 720,
        resizable: false,
        draggable: false,
        dialogClass: "detail-dialog",
        modal: true,
        closeText: "",
        close: function () {
            el.empty().remove();
        }
    });
    el.html("<img src='" + postUrl + "' style='width: 600px; height: 720px;' /><span class='btn-close'>X</span>");
    el.dialog({ position: ['center', 'center']});
    
    $(".ui-widget-overlay, #detail_dialog .btn-close").click(function () {
        $("#detail_dialog").dialog("close");
    });
    
    $("#detail_dialog .btn-close").mouseenter(function (ev) {
        $(this).addClass("btn-close-hover");
    })
    .mouseleave(function (ev) {
        $(this).removeClass("btn-close-hover");
    });
};

$(document).ready(function () {
    try { document.execCommand("BackgroundImageCache",false,true);} catch (e) {}
    
    setupContact();
});